{include /common/header}
<form action="{:\mylib\Route::buildUrl('/admin/channel/edit')}" method="POST">
    <fieldset>
        <legend>编辑栏目</legend>

        {php}function _show($channels, $_pid, $pid=0, $level=1){{/php}
            {foreach $channels as $v}
            {if $v['pid'] == $pid && $v['type'] == 'channel'}
                <option value="{$v.id}" {if $_pid == $v['id']}selected{/if}>{:str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level)}├&nbsp;{$v.title}</option>
                {:_show($channels, $_pid, $v['id'], $level+1)}
            {/if}
            {/foreach}
        {php}}{/php}
        <div class="form-group">
            <label>父栏目</label>
            <select class="form-control" name="pid" required>
                <option value="0" {if !$channel['pid']}selected{/if}>顶级栏目</option>
                {:_show($channels, $channel['pid'])}
            </select>
        </div>

        <div class="form-group">
            <label>目录名称</label>
            <input type="text" class="form-control" name="path" value="{$channel.path}" required>
            <span class="help-block">'/'开头</span>
        </div>

        <div class="form-group">
            <label>标题</label>
            <input type="text" class="form-control" name="title" value="{$channel.title}" required>
        </div>

        <div class="form-group">
            <label>关键词</label>
            <input type="text" class="form-control" name="keywords" value="{$channel.keywords}">
        </div>

        <div class="form-group">
            <label>简介</label>
            <textarea class="form-control" name="description" cols="80" rows="3">{$channel.description}</textarea>
        </div>

        {if $channel['type'] == 'channel'}
        <div class="form-group">
            <label>封面模板</label>
            <input type="text" class="form-control" name="tpl" value="{$channel.tpl}">
        </div>

        <div class="form-group">
            <label>跳转地址</label>
            <input type="text" class="form-control" name="jump" value="{$channel.jump}">
        </div>
        {/if}

        {if $channel['type'] == 'list'}
        <div class="form-group">
            <label>栏目模板</label>
            <input type="text" class="form-control" name="tpl" value="{$channel.tpl}">
        </div>

        <div class="form-group">
            <label>内容默认模板</label>
            <input type="text" class="form-control" name="tpl_detail" value="{$channel.tpl_detail}">
        </div>

        <div class="form-group">
            <label>模型扩展</label>
            <select class="form-control" name="model_id" required>
                <option value="0" {if '0' == $channel['model_id']}selected{/if}>不扩展</option>
                {foreach $models as $v}
                <option value="{$v.id}" {if $v['id'] == $channel['model_id']}selected{/if}>{$v.title}</option>
                {/foreach}
            </select>
            <span class="help-block"><a href="{:\mylib\Route::buildUrl('/admin/model/index')}" target="main">模型管理</a></span>
        </div>

        <div class="form-group">
            <label>是否允许投稿</label>
            <select class="form-control" name="contribute" required>
                <option value="0" {if 0 == $channel['contribute']}selected{/if}>不允许</option>
                <option value="1" {if 1 == $channel['contribute']}selected{/if}>允许</option>
            </select>
        </div>

        <div class="form-group">
            <label>分页大小</label>
            <input type="number" class="form-control" name="pagenum" value="{$channel.pagenum}">
        </div>
        {/if}

        {if $channel['type'] == 'page'}
        <div class="form-group">
            <label>单页模板</label>
            <input type="text" class="form-control" name="tpl" value="{$channel.tpl}">
        </div>

        <div class="form-group">
            <label>内容</label>
            <textarea name="body" rows="6" class="form-control xheditor {urlType:'abs',html5Upload:true,upMultiple:true,upLinkUrl:'{:\mylib\Route::buildUrl('/admin/api/xhupload')}',upLinkExt:'zip,rar,txt',upImgUrl:'{:\mylib\Route::buildUrl('/admin/api/xhupload')}',upImgExt:'jpg,jpeg,gif,png',upFlashUrl:'{:\mylib\Route::buildUrl('/admin/api/xhupload')}',upFlashExt:'swf',upMediaUrl:'{:\mylib\Route::buildUrl('/admin/api/xhupload')}',upMediaExt:'avi'}">{$channel.body}</textarea>
        </div>
        {/if}

        {if $channel['type'] == 'jump'}
        <div class="form-group">
            <label>跳转地址</label>
            <input type="text" class="form-control" name="jump" value="{$channel.jump}">
        </div>
        {/if}

        <div class="form-group">
            <label>打开方式</label>
            <select class="form-control" name="target" required>
                <option value="_self" {if $channel['target'] == '_self'}selected{/if}>当前窗口</option>
                <option value="_blank" {if $channel['target'] == '_blank'}selected{/if}>新窗口</option>
            </select>
        </div>

        <div class="form-group">
            <label>导航显示</label>
            <select class="form-control" name="nav" required>
                <option value="1" {if $channel['nav'] == '1'}selected{/if}>显示</option>
                <option value="0" {if $channel['nav'] == '0'}selected{/if}>不显示</option>
            </select>
        </div>

        <div class="form-group">
            <label>是否发布</label>
            <select class="form-control" name="status" required>
                <option value="1" {if $channel['status'] == '1'}selected{/if}>发布</option>
                <option value="0" {if $channel['status'] == '0'}selected{/if}>不发布</option>
            </select>
        </div>

        <div class="form-group">
            <label>排序</label>
            <input type="number" class="form-control" name="weight" value="0">
        </div>

        <input type="hidden" name="id" value="{$channel.id}">
        <button type="submit" class="btn btn-primary">提交</button>
    </fieldset>
</form>
{include /common/footer}